#!/rescue/sh

if [ ! -e /dev/md2 ] ; then
  halt -p
fi

echo "==> Unset rescue init kernel environment variables"
kenv -u init_chroot
kenv -u init_path
kenv -u init_script
kenv -u init_shell
echo "==> Unmount filesystems for cloning"
umount -f /livecd/dev
zpool export livecd
umount -f /cdrom
echo "== Set /dev/md2 device for reroot"
kenv vfs.root.mountfrom=zfs:livecd
echo "==> Rerooting into memdisk"
reboot -r
